<!DOCTYPE html>
<html>
  
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  <meta name="author" content="Amos Zhu">
  
  
  <title>Centos7下RabbitMQ的搭建 | Amos的技术博客</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="rabbitMQ,centos7,rabbitMQ,">
  

  
  <meta name="description" content="接下来我们来整理学习下RabbitMQ的相关技能点，工欲善其事必先利其器，我们首先来理解RabbitMQ的一些特性，我们为什么选择RabbitMQ来作为我们的消息中间件。">

  

  
    <script src="//cdn.jsdelivr.net/npm/leancloud-storage@3.11.1/dist/av-min.js" async></script>
  

  
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
  

  
    <script src="//unpkg.com/valine/dist/Valine.min.js" async></script>
  

  

  <script>
  // theme-ad's config script
  // it can be used in every script
  
  window.AD_CONFIG = {
    leancloud: {"appid":"eObxCkTJ6j4GzRxGLgiHyfJa-gzGzoHsz","appkey":"fzRMAFC6MCE11mp7mnvh4Kwe","comment":true,"count":true},
    welcome: {"enable":true,"interval":30},
    start_time: "2019-05-28",
    passwords: ["efe07af7441da2b69c4a41e42e73be4db47f66010a56900788a458354a7373ec", ],
    is_post: true,
    lock: false,
    author: "Amos Zhu",
    share: {"qq":true,"wechat":true},
    mathjax: true,
    page_type: "",
    root: "/blog/"
  };
</script>

  <script src="/blog/vendor/sha256.min.js"></script>
<script src="/blog/js/auth.js"></script>
<script src="/blog/js/index.js"></script>
<script src="/blog/vendor/qrcode.min.js"></script>

  
    <link rel="icon" href="/blog/images/favicon.ico">
    <link rel="apple-touch-icon" href="/blog/images/touch-icon.png">
  

  <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

  <link rel="stylesheet" href="/blog/css/index.css">
<link rel="stylesheet" href="/blog/styles/components/highlight/highlight.css">

  
</head>
  <body>
    <header class="site-header">
  <div class="site-header-brand">
    
      <span class="site-header-brand-title">
        <a href="/blog/">Amos Zhu</a>
      </span>
    
    
      <span class="site-header-brand-motto"> | 当浮躁的心静不下，不妨写些东西或者看会书</span>
    
  </div>
  <div class="site-header-right">
    <nav class="site-header-navigation">
      
        <a href="/blog/" target="_self">首页</a>
      
        <a href="/blog/archives/" target="_self">归档</a>
      
        <a href="/blog/tags/" target="_self">标签</a>
      
        <a href="/blog/categories/" target="_self">分类</a>
      
        <a href="/blog/redis/" target="_self">redis</a>
      
        <a href="/blog/rabbitMQ/" target="_self">rabbitMQ</a>
      
        <a href="/blog/elasticsearch" target="_self">elasticsearch</a>
      
        <a href="/blog/stuff" target="_self">stuff</a>
      
        <a href="/blog/kafka" target="_self">kafka</a>
      
        <a href="/blog/friends/" target="_self">友链</a>
      
        <a href="/blog/about/" target="_self">关于</a>
      
    </nav>
    <div class="site-header-btn">
      
        <a href="https://gitee.com/amos_zhu" target="_blank" id="site-github">
          <i class="fa fa-github-alt"></i>
        </a>
      
      <a href="javascript:void(0);" id="site-search">
        <i class="fa fa-search"></i>
      </a>
      <a href="javascript:void(0);" id="site-nav-btn">
        <i class="fa fa-ellipsis-v"></i>
      </a>
    </div>
  </div>
</header>
<nav class="table-content" id="site-nav">
  <div class="table-content-title">
    <span>导航</span>
  </div>
  <div class="table-content-main">
    <ol class="toc">
      
        <li class="toc-item">
          <a href="/blog/" target="_self">
            首页
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/archives/" target="_self">
            归档
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/tags/" target="_self">
            标签
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/categories/" target="_self">
            分类
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/redis/" target="_self">
            redis
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/rabbitMQ/" target="_self">
            rabbitMQ
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/elasticsearch" target="_self">
            elasticsearch
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/stuff" target="_self">
            stuff
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/kafka" target="_self">
            kafka
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/friends/" target="_self">
            友链
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/about/" target="_self">
            关于
          </a>
        </li>
      
    </ol>
  </div>
</nav>
<div id="site-process"></div>
    <main>
      
  <div class="passage">
  <div class="passage-meta">
    <span>
      <i class="fa fa-calendar"></i>2019-06-24
    </span>
    
      <span>
        | <a href="/blog/categories/rabbitMQ/"><i class="fa fa-bookmark"></i>rabbitMQ</a>
      </span>
    
    
      <span>
        | <i class="fa fa-unlock-alt"></i>UNLOCK
      </span>
    
  </div>
  <h1 class="passage-title">
    Centos7下RabbitMQ的搭建
  </h1>
  
  <article class="passage-article">
    <p></p>
<h2 id="带着问题去学习"><a href="#带着问题去学习" class="headerlink" title="带着问题去学习"></a>带着问题去学习</h2><p>OK,还是延续我们之前的学习特定，带着问题去学习，我们先了解下：</p>
<ol>
<li>什么是rabbitMQ？</li>
<li>rabbitMQ的一些主要的特性和优缺点</li>
<li>rabbitMQ能为我们解决什么样的问题，主要的运用场景有哪些</li>
<li>rabbitMQ的环境的搭建</li>
</ol>
<h2 id="RabbitMQ的简介"><a href="#RabbitMQ的简介" class="headerlink" title="RabbitMQ的简介"></a>RabbitMQ的简介</h2><h3 id="消息中间件"><a href="#消息中间件" class="headerlink" title="消息中间件"></a>消息中间件</h3><p>说到RabbitMQ，我们一般将其理解为消息中间件（消息队列中间件），那什么是消息中间件呢？</p>
<blockquote>
<ol>
<li>指利用高效可靠的消息传递机制进行与平台无关的数据交流，并基于数据通信来进行分布式系统的集成</li>
<li>一般有两种模式：点对点（P2P,Point-to-Point)模式和发布/订阅（Pub/Sub）模式</li>
</ol>
</blockquote>
<p>点对点模式是基于消息队列的，消息消费者从队列中接收消息，队列的存在使得消息的异步传输存在可能<br>发布订阅模式定义了如何向内容节点发布和订阅消息，这个内容节点称之为主题(topic),主题可以认为是消息传递的中介。消息发布者将这个消息发布到某个主题，而消息订阅者从这个主题订阅消息，主题使得消息的订阅者和消息的发布者可以独立存在。</p>
<h3 id="消息中间件的优点"><a href="#消息中间件的优点" class="headerlink" title="消息中间件的优点"></a>消息中间件的优点</h3><p>消息中间件具有如下的优点：</p>
<ol>
<li>解耦</li>
<li>冗余（存储）</li>
<li>扩展性</li>
<li>削峰</li>
<li>可恢复性</li>
<li>顺序保证性</li>
<li>缓冲</li>
<li>异步通讯</li>
</ol>
<h3 id="RabbitMQ"><a href="#RabbitMQ" class="headerlink" title="RabbitMQ"></a>RabbitMQ</h3><p>rabbitMQ是基于JMS的一种消息中间件的实现，他除了具有消息中间件的所有的特点，还具有如下的特点：</p>
<ol>
<li>相对于Kafka，rabbitMQ虽然在效率上有所不如，但是在数据安全上更胜一筹</li>
<li>rabbitMQ提供理货的路由来处理消息订阅</li>
<li>rabbitMQ可以构成集群，扩展性很好</li>
<li>rabbitMQ的集群可以设置虚拟节点来达到高可用</li>
<li>rabbitMQ支持多种协议：AMQP、STOMP、MQTT等多种协议</li>
<li>rabbitMQ含有web界面，可以监控和管理消息、集群中的节点等</li>
<li>rabbitMQ提供多种插件来进行多方面的扩展</li>
</ol>
<p>rabbitMQ的数据安全和高可用以及集群方便了我们再生产中处理一些对数据完整和安全性要求较高的功能。比如说企业与企业之间的数据通讯等</p>
<h2 id="RabbitMQ的安装"><a href="#RabbitMQ的安装" class="headerlink" title="RabbitMQ的安装"></a>RabbitMQ的安装</h2><p>我们在Centos7上安装RabbitMQ环境</p>
<blockquote>
<p>当前使用的版本 erlang: otp_src_22.0.tar.gz  rabbitMQ: rabbitmq-server-generic-unix-3.7.15.tar.xz</p>
</blockquote>
<h3 id="Erlang环境的搭建"><a href="#Erlang环境的搭建" class="headerlink" title="Erlang环境的搭建"></a>Erlang环境的搭建</h3><p>RabbitMQ是基于Erlang语言开发的，所以先要安装Erlang的环境<br>Erlang的下载地址如下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local</span><br><span class="line">## 安装erlang编译需要的环境</span><br><span class="line">yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl</span><br><span class="line">## 下载Erlang</span><br><span class="line">wget http://erlang.org/download/otp_src_22.0.tar.gz</span><br><span class="line">## 解压</span><br><span class="line">tar -zxvf otp_src_22.0.tar.gz</span><br><span class="line">## 配置</span><br><span class="line">cd otp_src_22.0</span><br><span class="line">./configure --prefix=/usr/local/erlang</span><br><span class="line"></span><br><span class="line">## 编译 这里要等待n长时间</span><br><span class="line">make &amp;&amp; make install</span><br><span class="line"></span><br><span class="line">## 修改环境变量</span><br><span class="line">vi /etc/profile</span><br><span class="line">## 添加</span><br><span class="line">ERLANG_HOME = /usr/local/erlang</span><br><span class="line">export PATH = $PATH:$ERLANG_HOME/bin</span><br><span class="line">export ERLANG_HOME</span><br><span class="line">## 让配置文件生效</span><br><span class="line">source /etc/profile</span><br><span class="line">## 查看是否安装成功</span><br><span class="line">erl</span><br></pre></td></tr></table></figure></p>
<h3 id="RabbitMQ的环境的搭建"><a href="#RabbitMQ的环境的搭建" class="headerlink" title="RabbitMQ的环境的搭建"></a>RabbitMQ的环境的搭建</h3><p>为了避免出现版本不兼容的问题，在搭建rabbitMQ之前，我们先来查看下erlang和rabbitMQ版本之间的关系，参考官网上：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://www.rabbitmq.com/which-erlang.html</span><br></pre></td></tr></table></figure></p>
<p><img src="https://s2.ax1x.com/2019/06/24/ZkxB5T.png" alt></p>
<p>我们根据对照表我们下载对应的rabbitMQ的安装包<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">## 下载 rabbitMQ centos7版本得压缩包</span><br><span class="line">https://github-production-release-asset-2e65be.s3.amazonaws.com/924551/eef64000-79e8-11e9-8998-5d172c09efb5?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190624%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20190624T090336Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=ef366e41fc1face2a01759cf60968f14c78ef46175fbf05999a745f7ad4d0fd2&amp;X-Amz-SignedHeaders=host&amp;actor_id=13399738&amp;response-content-disposition=attachment%3B%20filename%3Drabbitmq-server-generic-unix-3.7.15.tar.xz&amp;response-content-type=application%2Foctet-stream</span><br></pre></td></tr></table></figure></p>
<p>官网上提供的xz的安装包，所以我们先要安装xz</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">## 安装xz</span><br><span class="line">yum install xz</span><br><span class="line">## 解压</span><br><span class="line">xz -d rabbitmq-server-generic-unix-3.7.15.tar.xz</span><br><span class="line">tar -xvf rabbitmq-server-generic-unix-3.7.15.tar rabbitmq</span><br><span class="line">## 修改配置文件</span><br><span class="line">vi /etc/profile</span><br><span class="line">RABBITMQ_HOME=/usr/local/rabbitmq</span><br><span class="line">export PATH=$PATH:$RABBITMQ_HOME/sbin</span><br><span class="line">export RABBITMQ_HOME</span><br><span class="line">## 配置文件生效</span><br><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
<p>rabbitMQ 安装完成之后，我们需要让rabbitMQ运行起来<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">## 命令启动 -detached 后台启动</span><br><span class="line">rabbitmq-server -detached</span><br><span class="line">## 查看启动状态 有规律的一坨就是证明启动成功了</span><br><span class="line">rabbitmqctl status</span><br><span class="line"></span><br><span class="line">## 添加用户</span><br><span class="line">rabbitmqctl add_user root root</span><br><span class="line"></span><br><span class="line">## 授权</span><br><span class="line">rabbitmqctl set_permissions -p / root &quot;.*&quot; &quot;.*&quot; &quot;.*&quot;</span><br><span class="line">## 分配角色</span><br><span class="line">rabbitmqctl set_user_tags root administrator</span><br><span class="line"></span><br><span class="line">## 启用网页插件</span><br><span class="line">rabbitmq-plugins enable rabbitmq_management</span><br></pre></td></tr></table></figure></p>
<p>ok！，至此单机版的rabbitMQ环境平台就已经搭建起来了，我们可以访问： <a href="http://192.168.56.156:15672" target="_blank" rel="noopener">http://192.168.56.156:15672</a> 并且输入用户名和密码：root/root<br><img src="https://s2.ax1x.com/2019/06/24/ZA3D2D.png" alt></p>
<p><strong>对于rabbitMQ搭建所需要的安装文件，这里提供下载，减少搜索安装的烦恼</strong></p>
<p><a href="https://pan.baidu.com/s/1PkPsIePq3RPoMyyTE8EW1w" target="_blank" rel="noopener">RabbitMQ安装文件</a></p>
<p>提取码：d7sb </p>
<h2 id="RabbitMQ的相关概念的介绍"><a href="#RabbitMQ的相关概念的介绍" class="headerlink" title="RabbitMQ的相关概念的介绍"></a>RabbitMQ的相关概念的介绍</h2><blockquote>
<p>rabbitMQ是生产者与消费者模型，相当于邮件系统，发件人相当于生产者，收件人相当云消费者，那么rabbitMQ就相当于邮局，负责接收生产者的消息，推送给消费者对应的消息</p>
</blockquote>
<p>其主要的业务模型如下图：</p>
<p><img src="https://s2.ax1x.com/2019/06/24/ZAtcNR.png" alt></p>
<h3 id="队列"><a href="#队列" class="headerlink" title="队列"></a>队列</h3><p>是RabbitMQ的内部对象，用于存储消息且消息只能存在队列中，这点和kafka正好相反，kafka键将数据存储在topic中。</p>
<p>多个消费者可以订阅同一个队列，这时队列中的消息会被平均均摊给多个消费者进行消费，而不是每个消费都接收到消息进行处理。</p>
<h3 id="交换器、路由键、绑定"><a href="#交换器、路由键、绑定" class="headerlink" title="交换器、路由键、绑定"></a>交换器、路由键、绑定</h3><ol>
<li>Exchange</li>
</ol>
<p>生产者将消息发送到Exchange中，然后由exchange将消息路由到一个或者多个队列中，exchange有四种类型：direct、fanout、topic、headers四种类型</p>
<ul>
<li>fanout</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">会把所有放松到该交换器的消息路由到所有与该交换器绑定的队列中</span><br></pre></td></tr></table></figure>
<ul>
<li>direct</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">会把消息路由到BindingKey和RoutingKey相同的队列中</span><br></pre></td></tr></table></figure>
<ul>
<li>topic</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">会把消息路由到BindingKey和RoutingKey相匹配的队列中</span><br></pre></td></tr></table></figure>
<ul>
<li>headers</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">根据发送消息的内容中的headers属性进行匹配</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>RoutingKey：</li>
</ol>
<p>路由键，生产者将消息发送给消费者，一般会指定一个RoutingKey,用来指定这个消息的路由规则，而这个Routing Key需要和交换器类型和绑定键（Binding Key)联合才能生效<br><strong>RoutingKey 决定消息的流向</strong></p>
<ol start="3">
<li>Binding<br>绑定：RabbitMQ通过绑定将交换器和队列关联在一起</li>
</ol>
<p><img src="https://s2.ax1x.com/2019/06/24/ZAtfgK.png" alt></p>
<blockquote>
<p>在这里，如果利用邮局系统过来比喻的话，RoutingKey就相当于包裹上的地址，而BindingKey就相当于包裹的目的地</p>
</blockquote>
<p>是的，按照上面的比喻，那么RoutingKey和BindingKey是可以是相同的，这个是正确的，这个主要是在 direct类型下，才是一样的，如果是topic类型的话，RoutingKey和BindingKey是不同的</p>
<h2 id="RabbitMQ运转流程"><a href="#RabbitMQ运转流程" class="headerlink" title="RabbitMQ运转流程"></a>RabbitMQ运转流程</h2><h3 id="生产者发送消息"><a href="#生产者发送消息" class="headerlink" title="生产者发送消息"></a>生产者发送消息</h3><ul>
<li>生产者链接到RabbitMQ Broker,建立一个Connection,开启一个通道Channel</li>
<li>生产者声明一个交换器，并设置相关属性</li>
<li>生产者声明一个队列并且设置相关属性</li>
<li>生产者通过RoutingKey和BindingKey将交换器和队列关联在一起</li>
<li>如果找到，将消息存入到队列中</li>
<li>如果找不到，根据生产者配置的属性选择丢弃还是回退给生产者</li>
<li>关闭Channel</li>
<li>关闭Connection<h3 id="消费者接受消息"><a href="#消费者接受消息" class="headerlink" title="消费者接受消息"></a>消费者接受消息</h3></li>
<li>消费者链接到RabbitMQ Broker,建立一个Connection，并开启一个通道Channel</li>
<li>消费者想RabbitMQ Broker中请求队列中消息，可能会设置相应的回调函数以及做一些准备工作</li>
<li>等待RabbitMQ Broker中回应并且投递对应队列中的消息，消费者接收消息</li>
<li>消费者确认（ack）接受到的消息</li>
<li>RabbitMQ从队列中删除相应的已经被确认的消息</li>
<li>关闭Channel</li>
<li>关闭Connection</li>
</ul>
<p>为什么使用Channel呢？</p>
<p><strong>Channel是建立在Connection上的，主要是处理AMQP的指令，我们也可以是用Connection来完成Channel的工作，但是在高并发的场景下，有很多的线程需要到RabbitMQ中消费消息，如果是使用Connection来完成的话，我们需要穿件多个Connection来完成该任务，这样会造成很高的开销，很容造成系统性能瓶颈，所以我们采用NIO中的做法，选择TCP的选择复用，每个线程把持一个Channel，当每个Channel中流量不是很大时，复用单一的Connection可以有效的节省TCP的链接资源， 但是Channel中的流量很大时，再复用Connection就会产生性能瓶颈，进而使整个流量被限制，就要开辟多个Connection</strong></p>
  </article>
  <aside class="table-content" id="site-toc">
  <div class="table-content-title">
    <i class="fa fa-arrow-right fa-lg" id="site-toc-hide-btn"></i>
    <span>目录</span>
  </div>
  <div class="table-content-main">
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#带着问题去学习"><span class="toc-text">带着问题去学习</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#RabbitMQ的简介"><span class="toc-text">RabbitMQ的简介</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#消息中间件"><span class="toc-text">消息中间件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#消息中间件的优点"><span class="toc-text">消息中间件的优点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#RabbitMQ"><span class="toc-text">RabbitMQ</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#RabbitMQ的安装"><span class="toc-text">RabbitMQ的安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Erlang环境的搭建"><span class="toc-text">Erlang环境的搭建</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#RabbitMQ的环境的搭建"><span class="toc-text">RabbitMQ的环境的搭建</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#RabbitMQ的相关概念的介绍"><span class="toc-text">RabbitMQ的相关概念的介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#队列"><span class="toc-text">队列</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#交换器、路由键、绑定"><span class="toc-text">交换器、路由键、绑定</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#RabbitMQ运转流程"><span class="toc-text">RabbitMQ运转流程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#生产者发送消息"><span class="toc-text">生产者发送消息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#消费者接受消息"><span class="toc-text">消费者接受消息</span></a></li></ol></li></ol>
  </div>
</aside>
  
    <aside class="passage-copyright">
      <div>本文作者: Amos Zhu</div>
      
        <div>
          原文链接: 
          <a href target="_blank">http://amos_zhu.gitee.io/passages/Centos7下RabbitMQ的搭建/</a>
        </div>
      
      <div>
        版权声明: 本博客所有文章除特别声明外, 均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议. 转载请注明出处!
      </div>
    </aside>
  
  
    <div class="passage-tags">
     
      <a href="/blog/tags/centos7/"><i class="fa fa-tags"></i>centos7</a>
     
      <a href="/blog/tags/rabbitMQ/"><i class="fa fa-tags"></i>rabbitMQ</a>
    
    </div>
  
</div>

    </main>
    
      
<div class="site-comment-contanier" data-plateform="leancloud">
  
    <p id="site-comment-info">
      <i class="fa fa-spinner fa-spin"></i> 评论加载中
    </p>
    <div id="site-comment"></div>
  
</div>
    
    <div class="site-footer-wrapper">
  <footer class="site-footer">
    
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">博客推荐</h5>
          
            <span class="site-footer-item">
              <a href="http://youzhixueyuan.com/series/java" target="_blank">优知学院</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://ruanyifeng.com/" target="_blank">阮一峰的个人网站</a>
            </span>
          
        </div>
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">系列教程</h5>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/redis" target="_blank">Redis系列教程</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/rabbitMQ/" target="_blank">RabbitMQ教程</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/kafka/" target="_blank">Kafka架构探险</a>
            </span>
          
        </div>
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">抓到我</h5>
          
            <span class="site-footer-item">
              <a href="https://gitee.com/amos_zhu" target="_blank">Gitee</a>
            </span>
          
            <span class="site-footer-item">
              <a href="https://blog.csdn.net/wdcl2468" target="_blank">CSDN</a>
            </span>
          
            <span class="site-footer-item">
              <a href="https://www.jianshu.com/u/2dbe61b1f3c3" target="_blank">简书</a>
            </span>
          
        </div>
      
    
    <div class="site-footer-info">
      <i class="fa fa-clock-o"></i> 本站已稳定运行<span id="site-time"></span>
    </div>
    
      <div class="site-footer-info">
        <i class="fa fa-paw"></i> 您是本站第 <span id="site-count"></span> 位访客
      </div>
    
    
      <div class="site-footer-info">
        <i class="fa fa-at"></i> Email: amoszhu@aliyun.com
      </div>
    
    <div class="site-footer-info">
      <i class="fa fa-copyright"></i> 
      2019 <a href="https://github.com/dongyuanxin/theme-ad/" target="_blank">Theme-AD</a>.
      Created by <a href="https://godbmw.com/" target="_blank">GodBMW</a>.
      All rights reserved.
    </div>
  </footer>
</div>
    <div id="site-layer" style="display:none;">
  <div class="site-layer-content">
    <div class="site-layer-header">
      <span class="site-layer-header-title" id="site-layer-title"></span>
      <i class="fa fa-close" id="site-layer-close"></i>
    </div>
    <div class="site-layer-body" id="site-layer-container">
      <div class="site-layer-input" id="site-layer-search" style="display: none;">
        <div class="site-layer-input-choose">
          <a href="javascript:void(0);" title="Change Search Engine">Google</a>
        </div>
        <input type="text">
        <i class="fa fa-search"></i>
      </div>
      
        <div class="site-layer-reward" id="site-layer-reward" style="display: none;">
          
            <div>
              <img src="/blog/images/wechat.png" alt="WeChat">
              
                <p>WeChat</p>
              
            </div>
          
            <div>
              <img src="/blog/images/alipay.png" alt="AliPay">
              
                <p>AliPay</p>
              
            </div>
          
        </div>
      
      <div id="site-layer-welcome" style="display:none;"></div>
    </div>
  </div>
</div>
    

<div class="bottom-bar">
  <div class="bottom-bar-left">
    <a href="/blog/passages/SpringBoot整合RabbitMQ——交换机和队列的管理和绑定/" data-enable="true">
      <i class="fa fa-arrow-left"></i>
    </a>
    <a href="/blog/passages/Redis场景应用实例/" data-enable="true">
      <i class="fa fa-arrow-right"></i>
    </a>
  </div>
  <div class="bottom-bar-right">
    <a href="javascript:void(0);" data-enable="true" id="site-toc-show-btn">
      <i class="fa fa-bars"></i>
    </a>
    
      <a href="#site-comment" data-enable="true">
        <i class="fa fa-commenting"></i>
      </a>
    
    <a href="javascript:void(0);" id="site-toggle-share-btn">
      <i class="fa fa-share-alt"></i>
    </a>
    
      <a href="javascript:void(0);" id="site-reward">
        <i class="fa fa-thumbs-up"></i>
      </a>
    
    <a href="javascript:void(0);" id="back-top-btn">
      <i class="fa fa-chevron-up"></i>
    </a>
  </div>
</div>
    <div id="share-btn">
  
  
  
  
    <a id="share-btn-qq" href="javascript:void(0);" target="_blank">
      <i class="fa fa-qq"></i>
    </a>
  
  
    <a id="share-btn-wechat" href="javascript:void(0);" target="_blank">
      <i class="fa fa-wechat"></i>
    </a>
  
</div>
    


  <script async>
  (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
          bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
          bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
  })();
  </script>



  <script async>
    (function(){
    var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?":"https://jspassport.ssl.qhimg.com/11.0.1.js?";
    document.write('<script src="' + src + '" id="sozz"><\/script>');
    })();
  </script>


    
  </body>
</html>